package com.wyyx.api;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wyyx.services.OrderDelectServices;
import com.wyyx.services.OrderUpdateServices;

import commons.Constants;
import commons.JsonResult;
import commons.JsonResultWriter;

/**
 * 更新地址、收件人、联系方式
 */
@WebServlet("/api/OrderUpdate")
public class OrderUpdateServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderId=request.getParameter("orderId") ;
		String orderAddress=request.getParameter("orderAddress") ;
		String orderUser=request.getParameter("orderUser") ;
		String orderTelphone=request.getParameter("orderTelphone") ;
		JsonResult result =null;
		try {
			OrderUpdateServices orderUpdateServices = new OrderUpdateServices();
			int num = orderUpdateServices.orderUpdate(orderId, orderAddress, orderUser, orderTelphone);
			if (num!=0) {
				result=new JsonResult("", "添加成功",Constants.STATUS_SUCCESS);
			} else {
				result=new JsonResult("", "添加失败",Constants.STATUS_NOTFOUND);
			}
		} catch (Exception e) {
			result=new JsonResult(e.getMessage(), "添加出错", Constants.STATUS_EX);
		}
		JsonResultWriter.writer(response, result);
	}
}
